package com.example.controller;


import com.example.domain.po.ProductionArea;
import com.example.domain.response.HttpResponse;
import com.example.domain.vo.CityOutput;
import com.example.domain.vo.RegionInformation;
import com.example.service.ProductionAreaService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/productionArea")
public class ProductionAreaController {
    private final ProductionAreaService productionAreaService;

    /**
     * 获取城市生产荔枝总量
     * @return
     */
    @GetMapping("/ttop")
    public HttpResponse<List<CityOutput>> getTopCity() {
        return HttpResponse.success(productionAreaService.getTopCity());
    }

    /**
     * 获取某个城市的所有厂区信息
     */
    @GetMapping("/region")
    public HttpResponse<List<RegionInformation>> getRegion(String city) {

        List<RegionInformation> list =productionAreaService.list(city);
        return HttpResponse.success(list);
    }
}
